/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package abricots.net.common;

import abricots.net.common.GameMessage.CommandsMessage;
import com.esotericsoftware.kryonet.Connection;
import abricots.net.common.GameMessage.GameTimeSyncMessage;
import abricots.net.common.GameMessage.EntityMessage;
import abricots.net.common.GameMessage.WorldDiffMessage;

/**
 *
 * @author charly
 */
public abstract class MessageDispatcher {

    public void dispatchMessage(Object message, Connection connection) {
        if (!GameMessage.class.isAssignableFrom(message.getClass())) {
            return;
        }
        if (GameTimeSyncMessage.class.isAssignableFrom(message.getClass())) {
            dispatchGameSyncMessage((GameTimeSyncMessage) message, connection);
        } else if (EntityMessage.class.isAssignableFrom(message.getClass())) {
            dispatchEntitymessage((EntityMessage) message, connection);
        } else if (WorldDiffMessage.class.isAssignableFrom(message.getClass())) {
            dispatchWorldDiffMessage((WorldDiffMessage) message, connection);
        } else if (CommandsMessage.class.isAssignableFrom(message.getClass())) {
            dispatchCommandsMessage((CommandsMessage) message, connection);
        }
    }

    public abstract void dispatchGameSyncMessage(GameTimeSyncMessage message, Connection connection);

    public abstract void dispatchEntitymessage(EntityMessage message, Connection connection);

    public abstract void dispatchWorldDiffMessage(WorldDiffMessage message, Connection connection);

    public abstract void dispatchCommandsMessage(CommandsMessage message, Connection connection);
}
